package com.yangguang.huahui.mvp.model;


import com.yangguang.huahui.api.NewsApi;
import com.yangguang.huahui.entity.ChatMessage;
import com.yangguang.huahui.entity.ChatStatus;
import com.yangguang.huahui.entity.ChatUser;
import com.yangguang.huahui.entity.Contact;
import com.yangguang.huahui.entity.FeedList;
import com.yangguang.huahui.entity.HttpResult;
import com.yangguang.huahui.net.NetManager;

import okhttp3.ResponseBody;
import rx.Observable;

/**
 * Created by Administrator on 2017/3/14.
 */

public class NewsModel {
    /**
     * 获取聊天个人信息
     * @param forid
     * @param toif
     * @return
     */
    public Observable<ChatUser> getInfo(String forid, String toif){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.getInfo(forid, toif);
    }

    /**
     * 发送消息
     * @param for_uid
     * @param to_uid
     * @param msg
     * @return
     */
    public Observable<HttpResult> sendMsg(String for_uid, String to_uid, String msg){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.sendMsg(for_uid, to_uid, msg);
    }

    /**
     * 发送反馈消息
     * @param uid
     * @param To_uid
     * @param projectId
     * @param type
     * @param msg
     * @return
     */
    public Observable<HttpResult> sendFeedMsg(String uid, String To_uid, String projectId, String type, String msg){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.sendFeedMsg(uid, To_uid, projectId, type, msg);
    }

    /**
     * 聊天消息列表
     * @param uid
     * @return
     */
    public Observable<ChatMessage> getChatList(String uid){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.getChatList(uid);
    }

    /**
     * 显示状态栏信息
     * @param for_uid
     * @param to_uid
     * @param id
     * @return
     */
    public Observable<ChatStatus> getStatus(String for_uid, String to_uid, String id){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.getChatStatus(for_uid, to_uid, id);
    }

    /**
     * 加好友
     * @param for_uid
     * @param to_uid
     * @param id
     * @param type
     * @return
     */
    public Observable<ChatStatus> addFriends(String for_uid, String to_uid, String id, String type){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.addFriends(for_uid, to_uid, id, type);
    }

    /**
     * 好友列表
     * @param uid
     * @param keywords
     * @return
     */
    public Observable<Contact> getFriends(String uid, String keywords){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.getFriends(uid, keywords);
    }

    public Observable<HttpResult> delete_friend(String for_uid, String to_uid){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.delete_friend(for_uid, to_uid);
    }

    public Observable<FeedList> getFeedList(String uid, int type){
        NewsApi newsApi = NetManager.getInstance().create(NewsApi.class);
        return newsApi.getFeedList(uid, type);
    }
}
